-
Notifications
You must be signed in to change notification settings - Fork 357
[WIP] Use force-quoting in R2dbcMappingContext by default #2047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Please do not merge this PR. It is not yet fully edited, and it is very likely that it will not be further edited. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I realized how many changes were required to support this, I started to feel that my approach might be flawed.
There shouldn't really be that many changes.
What I would expect is the change to the default configuration, i.e. the R2dbcMappingContext
and then tons of changes to the tests, since most of them use the default, which we are changing.
Everything else should stay the same, since we already support forced quoting if so configured.
Could you line out why you think you have to change so much more?
@@ -26,6 +26,7 @@ | |||
import java.util.function.Supplier; | |||
import java.util.stream.Collectors; | |||
|
|||
import org.jetbrains.annotations.TestOnly; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not using this annotation.
For example, in this test case assertion, I believe the correct SQL should be: INSERT INTO "the_table" ("THE_NAME") VALUES ($1) This is because, with the configuration that enforces the use of quoted identifiers enabled, all generated SQL should theoretically follow this rule — unless the user explicitly provides a full SQL string for execution. However, in practice, if we only change the default value in R2dbcMappingContext, the generated SQL does not meet this expectation. As a workaround to make the test case pass as expected, I modified how the table name is resolved at this location. Of course, I don’t believe this is the correct solution — I just use it as an example to demonstrate that this approach works. In my opinion, the ideal place to address this issue would be in the I’m considering whether I should wait for the Spring team and the community to have a discussion and reach a conclusion before moving forward with this. |
When I realized how many changes were required to support this, I started to feel that my approach might be flawed. Given that I don't fully understand the design, I felt that I shouldn't make such extensive modifications without fully understanding it.
In my understanding, when transforming an AST into SQL, special handling (such as formatting, ignoring comments, or quoting) is usually applied through a visitor.
However, in the current Spring implementation, the quoting behavior is decided at AST generation time rather than during SQL rendering.
This design means that if the quoting strategy needs to change, all related code must be modified, which increases the risk of omissions. Additionally, it is difficult to be certain which places do not require changes.
Therefore, I have temporarily put this work on hold and am seeking a better solution from the community.
@schauder suggested that I submit a PR to ensure that this issue is not missed in #1993